import sim, sim_items, main
from util import *
import random

class DartingPrefix(sim_items.Prefix):
    """
   "darting" prefix increases a weapon's speed by reducing attack Energy"
    """
    def __init__(self):
        super(DartingPrefix, self).__init__(
            "darting", # name
            # description: (gets tacked onto item description)
            "Certain weaponsmiths coat their wares in a rare solution including "
            "quickling blood and mercury.  Such weapons are but a blur "
            "as they cut through the air with great speed."  
        )

    def initialize(self, wearable):
        if not isinstance(wearable, sim_items.Weapon):
            raise ValueError('Tried to apply %r to non-weapon item: %r' % (self,
                wearable))

        super(DartingPrefix, self).initialize(wearable)

        multiplier = 0.10 + 0.2*random.random()
        self.attackEnergyMod = multiplier * wearable.attackEnergy

        wearable.attackEnergy -= self.attackEnergyMod

    def remove(self, wearable):
        super(DartingPrefix, self).remove(wearable)
        wearable.attackEnergy += self.attackEnergyMod
  

#========================================
thingClass = DartingPrefix

